package jmine.tec.rpc.common.serialization;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import jmine.tec.test.Builder;

/**
 * Builder de MockBean
 * 
 * @author lundberg
 */
public class MockBeanBuilder implements Builder<MockBean> {

    private Long id = 1L;

    private BigDecimal number = BigDecimal.TEN;

    private Boolean bool1 = Boolean.TRUE;

    private boolean bool2 = false;

    private String string = "testString";

    private List<String> stringList = new ArrayList<String>(Arrays.asList(new String[]{ "a", "b" }));

    private List<BigDecimal> numberList = new ArrayList<BigDecimal>(Arrays.asList(new BigDecimal[]{ BigDecimal.ZERO, BigDecimal.ONE }));

    private List<Boolean> booleanList = new ArrayList<Boolean>(Arrays.asList(new Boolean[]{ Boolean.TRUE, Boolean.FALSE }));

    private List<MockBean> objectList = new ArrayList<MockBean>();

    private Map<String, MockBean> map = new HashMap<String, MockBean>();

    private Set<MockBean> set = new HashSet<MockBean>();

    /**
     * @return MockBeanBuilder
     */
    public static MockBeanBuilder aBean() {
        return new MockBeanBuilder();
    }

    /**
     * {@inheritDoc}
     */
    public MockBean build() {
        MockBean bean = new MockBean();
        bean.setId(this.id);
        bean.setNumber(this.number);
        bean.setBool1(this.bool1);
        bean.setBool2(this.bool2);
        bean.setString(this.string);
        bean.setStringList(this.stringList);
        bean.setNumberList(this.numberList);
        bean.setBooleanList(this.booleanList);
        bean.setObjectList(this.objectList);
        bean.setMap(this.map);
        bean.setSet(this.set);
        return bean;
    }

    /**
     * @param anId the id to set
     * @return this
     */
    public MockBeanBuilder withId(Long anId) {
        this.id = anId;
        return this;
    }

    /**
     * @param aNumber the number to with
     * @return this
     */
    public MockBeanBuilder withNumber(BigDecimal aNumber) {
        this.number = aNumber;
        return this;
    }

    /**
     * @param aBool1 the bool1 to with
     * @return this
     */
    public MockBeanBuilder withBool1(Boolean aBool1) {
        this.bool1 = aBool1;
        return this;
    }

    /**
     * @param aBool2 the bool2 to with
     * @return this
     */
    public MockBeanBuilder withBool2(boolean aBool2) {
        this.bool2 = aBool2;
        return this;
    }

    /**
     * @param aString the string to with
     * @return this
     */
    public MockBeanBuilder withString(String aString) {
        this.string = aString;
        return this;
    }

    /**
     * @param aStringList the stringList to with
     * @return this
     */
    public MockBeanBuilder withStringList(List<String> aStringList) {
        this.stringList = aStringList;
        return this;
    }

    /**
     * @param aNumberList the numberList to with
     * @return this
     */
    public MockBeanBuilder withNumberList(List<BigDecimal> aNumberList) {
        this.numberList = aNumberList;
        return this;
    }

    /**
     * @param aBooleanList the booleanList to with
     * @return this
     */
    public MockBeanBuilder withBooleanList(List<Boolean> aBooleanList) {
        this.booleanList = aBooleanList;
        return this;
    }

    /**
     * @param anObjectList the objectList to with
     * @return this
     */
    public MockBeanBuilder withObjectList(List<MockBean> anObjectList) {
        this.objectList = anObjectList;
        return this;
    }
}
